<extend name="Base/common" />
<block name="style">
    {/**
    <link rel="stylesheet" type="text/css" href="__CSS__/font-awesome.min.css?v=20150803">
    <!--[if IE 7]>
    <link rel="stylesheet" href="__CSS__/font-awesome-ie7.min.css">
    <![endif]-->
    */}
    <style type="text/css">
        .register-box {
            float: none;
            margin: 8% auto;
        }
        .register-box .panel {
            border-color: #eee;
            padding: 20px 20px 0px 20px;
        }
        .register-box .input-group input, .register-box .input-group button {
            height: 40px;
        }
        .register-box .input-group-addon .fa {
            width: 18px;
        }
        .register-box .verifyimg-box {
            padding: 0px;
        }
        .register-box .verifyimg-box .verifyimg {
            width: 138px;
            height: 38px;
            cursor: pointer;
            border-radius: 4px;
        }
    </style>
</block>
<block name="body">
    <section>
        <div class="container" style="padding-left: 0;padding-right: 0;">
            <div class="col-xs-12 col-md-5 register-box">
                <div class="panel panel-default">
                    <h3 class="text-center">用户登录</h3>
                    <div class="panel-body">
                        <div class="reg-box">
                            <div class="login">
                                <div class="tab-content">
                                        <form class="login-form" action="__SELF__" method="post">
                                            <fieldset>
                                                <div class="form-group">
                                                    <div class="input-group">
                                                        <span class="input-group-addon"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></span>
                                                        <input type="text" class="form-control" placeholder="用户名"  ajaxurl="/member/checkUserNameUnique.html" errormsg="请填写1-16位用户名" nullmsg="请填写用户名" datatype="*1-16" value="" name="username">
                                                    </div>
                                                </div>
                                    <div class="form-group">
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="glyphicon glyphicon-lock" aria-hidden="true"></i></span>
                                            <input type="password" class="form-control" id="inputPassword" placeholder="密码"  errormsg="密码为6-20位" nullmsg="请填写密码" datatype="*6-20" name="password">
                                        </div>
                                    </div>
                                <!--div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-eye-open"></i></span>
                                        <input type="text" class="form-control" id="inputPassword" placeholder="验证码"  errormsg="请填写5位验证码" nullmsg="请填写验证码" datatype="*5-5" name="verify">
                                        <span class="input-group-addon verifyimg-box"> <img class="verifyimg reloadverify" alt="点击切换" src="{:U('verify')}" style="cursor:pointer;"> </span>
                                    </div>
                                </div-->
                                <div class="form-group">
                                    <label>
                                        <input type="checkbox">
                                        自动登录 </label>
                                    <button class="btn btn-primary btn-block submit" type="submit" target-form="reg-form-username">
                                        登 录
                                    </button>
                                    <div class="controls Validform_checktip text-warning"></div>
                                </div>
                                </fieldset>
                                </form>
                        </div>
                    </div>
                    <div class="form-group">
                            {:hook('SyncLogin')} <!-- 第三方登陆钩子 -->
                        </div>
                        <div class="form-group text-center">
                            <a class="text-muted" href="{:U('User/register')}">还没有账号？立即注册</a>
                        </div>
                </div>
            </div>
        </div>
        </div>
        </div>

    </section>
</block>

<block name="side"></block>
<block name="script">
    <script type="text/javascript">
        $(document).ajaxStart(function() {
            $("button:submit").addClass("log-in").attr("disabled", true);
        }).ajaxStop(function() {
            $("button:submit").removeClass("log-in").attr("disabled", false);
        });

        $("form").submit(function() {
            var self = $(this);
            $.post(self.attr("action"), self.serialize(), success, "json");
            return false;

            function success(data) {
                if (data.status) {
                    window.location.href = data.url;
                } else {
                    self.find(".Validform_checktip").text(data.info);
                    //刷新验证码
                    $(".reloadverify").click();
                }
            }

        });

        $(function() {
            var verifyimg = $(".verifyimg").attr("src");
            $(".reloadverify").click(function() {
                if (verifyimg.indexOf('?') > 0) {
                    $(".verifyimg").attr("src", verifyimg + '&random=' + Math.random());
                } else {
                    $(".verifyimg").attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random());
                }
            });
        });
    </script>
</block>
